﻿using System.Xml;
using System.Collections;

namespace XmlParser
{
    public abstract class IXmlObject
    {
        #region Processors

        /// <summary>
        /// Process the node as specified 
        /// </summary>
        /// <param name="NewXmlNode">The Node to be Processed.</param>
        internal abstract void ProcessNode(XmlNode NewXmlNode);

        /// <summary>
        /// recursivly Process all the child Nodes of the Node specified.
        /// </summary>
        /// <param name="NewXmlNode">The Node whose child node is required to be Processed.</param>
        internal abstract void ProcessChildNode(XmlNode NewXmlNode);

        #endregion Processors

        #region DeepClone

        public abstract IXmlObject Duplicate();

        protected abstract bool AddChildNode(IXmlObject NewXmlObject);

        protected abstract bool AddChildNodeAt(IXmlObject NewXmlObject, int AtIndex);

        protected abstract bool RemoveChildNode(IXmlObject NewXmlObject);

        #endregion DeepClone

        #region Properties

        protected abstract XmlNode XmlNodeCurrent { get; }

        /// <summary>
        /// Sets the value of an attribute.
        /// </summary>
        /// <param name="AttributeName">Name of Attribute.</param>
        /// <param name="AttributeValue">Value of Attribute.</param>
        protected abstract void SetAttribute(string AttributeName, string AttributeValue);

        /// <summary>
        /// To get the value of attribute specified by "AttributeName" parameter
        /// </summary>
        /// <param name="AttributeName">Name of the Attribute.</param>
        /// <returns>Value of the Attribute specified in "AttributeName" parameter.</returns>
        protected abstract string GetAttribute(string AttributeName);

        /// <summary>
        /// To produce Xml representation of IXmlObject
        /// </summary>
        /// <returns>String representing Xml of IXmlObject</returns>
        public abstract string ToXmlString();

        /// <summary>
        /// 
        /// </summary>
        //XmlNode XmlNodeCurrent{get;}

        /// <summary>
        /// Name of the XmlElement (TagName).
        /// </summary>
        public abstract string Name { get; set; }

        /// <summary>
        /// String between opening and closing tag of XmlElement.
        /// </summary>
        public abstract string Value { get; set; }

        /// <summary>
        /// Conains Attribute's name value pairs.
        /// </summary>
        protected abstract Hashtable Attributes { get; }

        /// <summary>
        /// Represent the Root Node's Name of the document.
        /// It will always be a single static value for all node of One Xml Document.
        /// </summary>
        public abstract string RootElementName { get; set; }
        
        public abstract string AssemblyFullName { get; set; }
        
        public abstract string AssemblyNamespace { get; set; }

        /// <summary>
        /// Contains Hashtables one for each ChildNode of one type.
        /// </summary>
        protected abstract Hashtable ChildrenNodesAll { get; }

        /// <summary>
        /// Provide Hash table for a selected type of Child Node
        /// </summary>
        /// <param name="XmlElementName">
        /// Name of an Xml Node representing Type of the child nodes required 
        /// </param>
        /// <returns>Hashtable of Child Nodes for a selected type of Child Node.</returns>
        protected abstract Hashtable ChildrenNodes(string XmlElementName);

        #endregion Properties
    }
}
